#include <iostream>
#include <algorithm>

using namespace std;

const int T = 1010;
int N, maxVolume;
int volumes[T], prices[T];
int dp[T][T];

int main()
{
    cin >> N >> maxVolume;
    for (int i = 1; i <= N; i++)
        cin >> volumes[i] >> prices[i];

    for (int i = 1; i <= N; i++)
        for (int j = 0; j <= maxVolume; j++)
            for (int k = 0; k * volumes[i] <= j; k++)
            {
                int v1 = dp[i - 1][j];
                int v2 = dp[i - 1][j - k * volumes[i]] + k * prices[i];
                dp[i][j] = max(v1, v2);
            }

    cout << dp[N][maxVolume] << endl;
    return 0;
}
